local jianzhengq = fk.CreateSkill {

  name = "joy__jianzhengq",

  tags = {  },

}



jianzhengq:addEffect(fk.TargetSpecifying, {
  name = "joy__jianzhengq",
  anim_type = "control",
  events = {fk.TargetSpecifying},
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(jianzhengq.name) and target ~= player and data.card.trueName == "slash" and data.firstTarget and
      not table.contains(data:getAllTargets(), player.id) and target:inMyAttackRange(player) and not player:isKongcheng()
  end,
  on_cost = function(self, event, target, player, data)
    local card = player.room:askForCard(player, 1, 1, false, jianzhengq.name, true, ".",
      "#joy__jianzhengq-invoke::"..target.id..":"..data.card:toLogString())
    if #card > 0 then
      event:setCostData(self, card)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    room:moveCards({
      ids = event:getCostData(self),
      from = player.id,
      fromArea = Card.PlayerHand,
      toArea = Card.DrawPile,
      moveReason = fk.ReasonJustMove,
      skillName = jianzhengq.name,
    })
    for _, id in ipairs(data:getAllTargets()) do
      data:cancelTarget(id)
    end
    if not player.dead and data.card.color ~= Card.Black then
      room:doIndicate(target.id, {player.id})
      data:addTarget(player.id)
    end
  end,
})

return jianzhengq